Array.prototype.my_every = function(fn, context) {
    const me = this

    const ctx = context ? context : this // 判断上下文

    if (typeof fn !== 'function') {
        throw new Error(`${fn} is not a function`)
    }
    
    let bool = true
    for (let i = 0; i < me.length; i++) {
        const res = fn.call(ctx, me[i], i, me)
        if (!res) {
            bool = false
            break
        }
    }
    return bool
}

const arr = [1,2,3,4]

console.log(arr.my_every((item) => item>2))

